import json
import unittest
from pathlib import Path

from video_summarize_tools.tools import ffmpeg_tools


class FFMpegToolsTest(unittest.TestCase):
    def test_sperate_stream(self):
        video_file = Path("/tmp/7b6c5df9-9211-4416-9b88-fd1b128a5b6e/The 3 Jazz Chord Rules Every Pro Knows (But Nobody Teaches).f96-13.mp4")
        streams = ffmpeg_tools.separate_stream(video_file)
        print(streams)


    def test_extract_frame_by_fps(self):
        video_file = Path("E:\\This Amazing Jazz Lick Changed My Playing Forever.mp4")
        target_dir = Path("E:\\ffmpeg_frame")
        if target_dir.exists():
            for f in target_dir.iterdir():
                f.unlink()
            target_dir.rmdir()
        target_dir.mkdir()

        list = ffmpeg_tools.extract_frame_by_fps(video_file, target_dir, fps=0.5)
        print(list)

    def test_ffprobe(self):
        video_file = Path("E:\\download\\NS1.mp4")
        print(ffmpeg_tools.query_video_info(video_file).json())
